package com.powernode.teatraceability.config;


import com.powernode.teatraceability.interceptors.AuthorizeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * ClassName: WebConfiguration
 * Description:
 *
 * @Author: jdz
 * @Create: 2023/4/21 - 23:36
 */
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
    @Resource
    AuthorizeInterceptor interceptor;

    /**
     * 在SpringSecurity过滤链中添加拦截器:
     * 通过 @Resource 注解注入了一个 AuthorizeInterceptor 的对象。
     * 然后，通过 InterceptorRegistry 的 addInterceptor 方法，
     * 将该拦截器添加到拦截器链中，并指定拦截器的拦截规则
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/api/auth/**", "/source/sym/**");
    }
}
